package com.deanna.java;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class CountDate {
	// ����ĳ��ĳ��ĳ�գ��ж���һ������һ��ĵڼ���
	@SuppressWarnings("deprecation")
	public static void main(String[] args) throws ParseException {
		System.out.println("������ʱ�䣨yyyy-mm-dd��:");
		Scanner scanner = new Scanner(System.in);
		String strDate = scanner.nextLine();
		SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
		Date date = formatDate.parse(strDate);
		int year = date.getYear();
		int month = date.getMonth();
		int day = date.getDate();
		int[] a = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		switch (month) {
		case 1:
			System.out.print("��һ������һ��ĵ�" + day + "��");
			break;
		case 2:
			System.out.print("��һ������һ��ĵ�" + (a[0] + day) + "��");
			break;
		case 3:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + day) + "��");
			}
			break;
		case 4:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + day) + "��");
			}
			break;
		case 5:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + a[3] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + a[3] + day) + "��");
			}
			break;
		case 6:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + a[3] + a[4] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + a[3] + a[4] + day) + "��");
			}
			break;
		case 7:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + a[3] + a[4] + a[5] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + a[3] + a[4] + a[5] + day) + "��");
			}
			break;
		case 8:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + a[3] + a[4] + a[5] + a[6] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + a[3] + a[4] + a[5] + a[6] + day) + "��");
			}
			break;
		case 9:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + day) + "��");
			}
			break;
		case 10:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + day) + "��");
			}
			break;
		case 11:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + day) + "��");
			}
			break;
		default:
			if (loopyear(year)) {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 29 + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + a[10] + day) + "��");
			} else {
				System.out.print("��һ������һ��ĵ�" + (a[0] + 28 + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] + a[10] + day) + "��");
			}
			break;

		}

	}

	private static boolean loopyear(int y) {
		if ((y % 4 == 0 & y % 100 > 0) | (y % 400 == 0)) {
			return true;
		} else {
			return false;
		}

	}
}
